package com.ruoyi.web.controller.pc;

import java.util.List;

import com.ruoyi.business.domain.WmsDeliveryPlan;
import com.ruoyi.business.service.IWmsDeliveryPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库计划Controller
 *
 * @author ruoyi
 * @date 2024-01-09
 */
@RestController
@RequestMapping("/system/deliveryPlan")
public class WmsDeliveryPlanController extends BaseController
{
    @Autowired
    private IWmsDeliveryPlanService wmsDeliveryPlanService;

    /**
     * 查询出库计划列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WmsDeliveryPlan wmsDeliveryPlan)
    {
        startPage();
        List<WmsDeliveryPlan> list = wmsDeliveryPlanService.selectWmsDeliveryPlanList(wmsDeliveryPlan);
        return getDataTable(list);
    }
//
//    /**
//     * 导出出库计划列表
//     */
//    @Log(title = "出库计划", businessType = BusinessType.EXPORT)
//    @GetMapping("/export")
//    public AjaxResult export(WmsDeliveryPlan wmsDeliveryPlan)
//    {
//        List<WmsDeliveryPlan> list = wmsDeliveryPlanService.selectWmsDeliveryPlanList(wmsDeliveryPlan);
//        ExcelUtil<WmsDeliveryPlan> util = new ExcelUtil<WmsDeliveryPlan>(WmsDeliveryPlan.class);
//        return util.exportExcel(list, "出库计划数据");
//    }

    /**
     * 获取出库计划详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wmsDeliveryPlanService.selectWmsDeliveryPlanById(id));
    }

    /**
     * 新增出库计划
     */
    @Log(title = "出库计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsDeliveryPlan wmsDeliveryPlan)
    {
        wmsDeliveryPlan.setCreateBy(getUsername());
        return toAjax(wmsDeliveryPlanService.insertWmsDeliveryPlan(wmsDeliveryPlan));
    }

    /**
     * 修改出库计划
     */
    @Log(title = "出库计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsDeliveryPlan wmsDeliveryPlan)
    {
        wmsDeliveryPlan.setUpdateBy(getUsername());
        return toAjax(wmsDeliveryPlanService.updateWmsDeliveryPlan(wmsDeliveryPlan));
    }

    @Log(title = "出库计划-取消", businessType = BusinessType.UPDATE)
    @PostMapping("cancel")
    public AjaxResult cancel(@RequestBody WmsDeliveryPlan wmsDeliveryPlan)
    {
        wmsDeliveryPlan.setUpdateBy(getUsername());
        return toAjax(wmsDeliveryPlanService.cancel(wmsDeliveryPlan));
    }


//
//    /**
//     * 删除出库计划
//     */
//    @Log(title = "出库计划", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(wmsDeliveryPlanService.deleteWmsDeliveryPlanByIds(ids));
//    }
}
